﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using prDe_Tai.DuLieu;

namespace prDe_Tai.trunggian
{
    class trunggian_danhsachphanmem
    {
        dulieu_danhsachphanmem obj = new dulieu_danhsachphanmem();
        public DataSet laydanhsachphanmemtheochude(string loaiphanmem, string chude)
        {
            return obj.laydanhsachphanmemtheochude(loaiphanmem, chude);           
        }
        public DataSet laytoanbophanmem()
        {
            return obj.laytoanbophanmem();
        }
        public DataSet demsoluongphanmemtheochude(string chude, string loaiphanmem)
        {           
            return obj.demsoluongphanmemtheochude(chude,loaiphanmem);
        }
        public DataSet demsoluongphanmemtrongchuongtrinh()
        {
            return obj.demsoluongphanmemtrongchuongtrinh();
        }
        public DataSet layphanmemtheotenphanmem(string tenphanmem)
        {
            return obj.layphanmemtheotenphanmem(tenphanmem);
        }
        public void xoadulieutrongbang(string tenphanmem)
        {
            obj.xoadulieutrongbang(tenphanmem);
        }        
        public void themdulieuvaobang(string tenphanmem, string chucnang, string diachidownload, string loaiphanmem, string chude,string hinh)
        {
            int sothutu;
            DataSet ds = obj.laysothutulonnhattrongcosodulieu();
            if (ds.Tables[0].Rows[0][0].ToString() == "")
                sothutu = 1;
            else
            sothutu = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString()) + 1;
            DataSet ds1 = obj.layphanmemtheotenphanmem(tenphanmem);
            if (ds1.Tables[0].Rows.Count == 0)
                obj.themdulieuvaobang(sothutu, tenphanmem, chucnang, diachidownload, loaiphanmem, chude, hinh);
            else if (tenphanmem.ToLower().Split(' ').ToString() == ds1.Tables[0].Rows[0]["tenphanmem"].ToString().ToLower().Split(' ').ToString())
            {
                throw new Exception("Tên phần mềm này đã có trong cơ sở dữ liệu     ");
            }                    
        }
        public void capnhatvaodatabase(DataTable dt)
        {
            obj.capnhatvaodatabase(dt);
        }
        public DataSet timkiemphanmemtheoten(string chuoi)
        {
            return obj.timkiemphanmemtheoten(chuoi);
        }
        public DataSet timkiemphanmemtheochucnang(string chuoi)
        {
            return obj.timkiemphanmemtheochucnang(chuoi) ;
        }
    }
}
